package cn.superchart.module.user.controller;

import cn.superchart.common.base.BaseController;
import cn.superchart.common.base.BaseResult;
import cn.superchart.module.user.param.*;
import cn.superchart.module.user.service.ScUserService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Validated
public class ScLoginController extends BaseController<ScUserService> {


    @PostMapping("/sc/user/login")
    public BaseResult<String> login(@RequestBody @Valid ScLoginParam scLoginParam) {
        return BaseResult.result(service.blogin(scLoginParam));
    }

    @PostMapping("/sc/user/logout")
    public BaseResult<String> logout(HttpServletRequest request, HttpServletResponse response) {
        service.logout(request,response);
        return BaseResult.ok();
    }

}
